package net.azure.app;

import net.azure.app.model.Story;
import net.azure.app.model.AzureSession;
import net.azure.app.util.CSVLoader;

import java.net.URL;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.io.IOException;
import java.io.File;

/**
 * Created by IntelliJ IDEA.
 * User: Venkatraman Kandaswamy : kvenkatraman@gmail.com
 * Date: 12-Jun-2008
 * Time: 06:58:17
 */
public class Azure358 {
    public static void main(String[] args) throws URISyntaxException {
        Azure instance = new Azure();
        URL url = Thread.currentThread().getContextClassLoader().getResource("./default.csv");
        loadSession(new File(url.toURI()));
        AzureSession.setDefaultStories(AzureSession.getStories());
        instance.configureUI();
        instance.buildInterface();
        AzureSession.setAzure(instance);
    }

    public static void loadSession(File file){
        HashMap<Integer, Story> stories;
        try {
            stories = CSVLoader.loadCSV(file);
        } catch (IOException e) {
            e.printStackTrace();
            return;
        }
        AzureSession.setStories(stories);
        AzureSession.setMSL(stories.keySet().toArray(new Integer[0])[0]);
    }

}   